/**
 * 权限边界控制，当用户没有角色或者权限时，不显示内部的子组件
 *
 * @roles : roles = "admin | secLevel"
 *
 * @perms : perms = "xxx | yyy"
 */
class SecurityCheck extends React.Component {
    constructor(props){
        super(props);
        let roleRight = true;
        let permRight = true;
        if(this.props.roles)
            roleRight = hasRoles(this.props.roles);
        if(this.props.perms)
            permRight = hasPerms(this.props.perms);

        this.hasPermission = roleRight && permRight;
    }

    render(){
        return (
            this.hasPermission?this.props.children:''
        )
    }

}
